INSERT INTO AssetType (ID, Name, Description) VALUES (8,'DER','DER governed by IEEE Standard 1547-2018')
GO

ALTER TABLE AccessLog ADD NodeID uniqueidentifier NOT NULL DEFAULT('00000000-0000-0000-0000-000000000000')
GO

CREATE TRIGGER TR_INSERT_Breaker ON Breaker
INSTEAD OF INSERT AS 
BEGIN
	INSERT INTO Asset (AssetKey, AssetTypeID, Description, VoltageKV, AssetName, Spare)
		SELECT 
			AssetKey AS AssetKey,
			(SELECT ID FROM AssetType WHERE Name = 'Breaker') AS AssetTypeID,
			Description AS Description,
			VoltageKV AS VoltageKV,
			AssetName AS AssetName,
			Spare AS Spare
	FROM INSERTED

	INSERT INTO BreakerAttributes (AssetID, ThermalRating, Speed, TripTime, PickupTime, TripCoilCondition, AirGapResistor)
		SELECT 
			(SELECT ID FROM Asset WHERE AssetKey = INSERTED.AssetKey) AS AssetID,
			ThermalRating AS ThermalRating,
			Speed AS Speed,
			TripTime AS TripTime,
			PickupTime AS PickupTime,
			TripCoilCondition AS TripCoilCondition,
            AirGapResistor AS AirGapResistor
	FROM INSERTED

END
GO

CREATE TRIGGER TR_UPDATE_Breaker ON Breaker
INSTEAD OF UPDATE AS
BEGIN
IF (UPDATE(AssetKey) OR UPDATE(Description) OR UPDATE (AssetName) OR UPDATE (VoltageKV) OR UPDATE(Spare))
	BEGIN
		UPDATE Asset
		SET
			Asset.AssetKey = INSERTED.AssetKey,
			Asset.Description = INSERTED.Description,
			Asset.AssetName = INSERTED.AssetName,
			Asset.VoltageKV = INSERTED.VoltageKV,
			Asset.Spare = INSERTED.Spare
		FROM
			ASSET 
		INNER JOIN
			INSERTED
		ON 
			INSERTED.ID = ASSET.ID;
	END
	UPDATE BreakerAttributes
		SET
			BreakerAttributes.ThermalRating = INSERTED.ThermalRating,
			BreakerAttributes.Speed = INSERTED.Speed,
			BreakerAttributes.TripTime = INSERTED.TripTime,
			BreakerAttributes.PickupTime = INSERTED.PickupTime,
			BreakerAttributes.TripCoilCondition = INSERTED.TripCoilCondition,
            BreakerAttributes.AirGapResistor = INSERTED.AirGapResistor
		FROM
			BreakerAttributes 
	INNER JOIN
		INSERTED
	ON 
		INSERTED.ID = BreakerAttributes.AssetID;
END
GO

CREATE TRIGGER TR_INSERT_LineSegment ON LineSegment
INSTEAD OF INSERT AS 
BEGIN
	INSERT INTO Asset (AssetKey, AssetTypeID, Description, AssetName, VoltageKV, Spare)
		SELECT 
			AssetKey AS AssetKey,
			(SELECT ID FROM AssetType WHERE Name = 'LineSegment') AS AssetTypeID,
			Description AS Description,
			AssetName AS AssetName,
			VoltageKV AS VoltageKV,
			Spare AS Spare
	FROM INSERTED

	INSERT INTO LineSegmentAttributes (AssetID, Length, R0, X0, R1, X1, ThermalRating, IsEnd, FromBus, ToBus)
		SELECT 
			(SELECT ID FROM Asset WHERE AssetKey = INSERTED.AssetKey) AS AssetID,
			Length AS Length,
			R0 AS R0,
			X0 AS X0,
			R1 AS R1,
			X1 AS X1,
			ThermalRating AS ThermalRating,
            IsEnd AS IsEnd,
            FromBus AS FromBus,
            ToBus AS ToBus
	FROM INSERTED

END
GO

CREATE TRIGGER TR_UPDATE_LineSegment ON LineSegment
INSTEAD OF UPDATE AS
BEGIN
IF (UPDATE(AssetKey) OR UPDATE(Description) OR UPDATE (AssetName) OR UPDATE(VoltageKV) OR Update(Spare))
	BEGIN
		UPDATE Asset
		SET
			Asset.AssetKey = INSERTED.AssetKey,
			Asset.Description = INSERTED.Description,
			Asset.AssetName = INSERTED.AssetName,
			Asset.VoltageKV  = INSERTED.VoltageKV,
			Asset.Spare = INSERTED.Spare
		FROM
			ASSET 
		INNER JOIN
			INSERTED
		ON 
			INSERTED.ID = ASSET.ID;
	END
	UPDATE LineSegmentAttributes
		SET
			LineSegmentAttributes.R0 = INSERTED.R0,
			LineSegmentAttributes.X0 = INSERTED.X0,
			LineSegmentAttributes.R1 = INSERTED.R1,
			LineSegmentAttributes.X1 = INSERTED.X1,
            LineSegmentAttributes.Length = INSERTED.Length,
			LineSegmentAttributes.ThermalRating = INSERTED.ThermalRating,
            LineSegmentAttributes.IsEnd = INSERTED.IsEnd,
            LineSegmentAttributes.FromBus = INSERTED.FromBus,
            LineSegmentAttributes.ToBus = INSERTED.ToBus
		FROM
			LineSegmentAttributes 
	INNER JOIN
		INSERTED
	ON 
		INSERTED.ID = LineSegmentAttributes.AssetID;
END
GO

CREATE TABLE ApplicationNode (
    ID UNIQUEIDENTIFIER NOT NULL DEFAULT NEWID() PRIMARY KEY,
    Name VARCHAR(200) NOT NULL
)
GO

INSERT INTO ApplicationNode VALUES ('00000000-0000-0000-0000-000000000000','OpenXDA')
GO

CREATE TABLE ApplicationSustainedUser (
    ID INT IDENTITY(1, 1) NOT NULL PRIMARY KEY,
    ApplicationNodeID  UNIQUEIDENTIFIER NOT NULL REFERENCES ApplicationNode(ID),
    UserAccountID  UNIQUEIDENTIFIER NOT NULL REFERENCES UserAccount(ID),
    Code VARCHAR(200) NOT NULL
)
GO

ALTER TABLE EmailType ADD
	Name VARCHAR(100) NOT NULL DEFAULT('Email Template'),
    Template VARCHAR(MAX) NOT NULL DEFAULT('Email Template'),
    TriggerEmailSQL VARCHAR(MAX) NOT NULL DEFAULT 'SELECT 0',
    CombineEventsSQL VARCHAR(MAX) NOT NULL DEFAULT 'SELECT ID FROM Event WHERE ID = {0}',
    MinDelay FLOAT NOT NULL DEFAULT 10,
    MaxDelay FLOAT NOT NULL DEFAULT 60,
    ShowSubscription BIT NOT NULL DEFAULT 1,
    RequireApproval BIT NOT NULL DEFAULT 0,
    FilePath VARCHAR(200) NULL DEFAULT NULL
GO

ALTER TABLE UserAccountEmailType ADD
	AssetGroupID INT NOT NULL REFERENCES AssetGroup(ID) DEFAULT 1,
	Approved BIT NOT NULL DEFAULT 0
GO

CREATE VIEW SubscribeEmails
AS
SELECT
    UserAccountEmailType.ID,
    UserAccountEmailType.Approved,
    EmailType.ID as EmailID,
    UserAccount.FirstName as FirstName,
    UserAccount.LastName as LastName,
    UserAccount.Email as Email,
    AssetGroup.Name as AssetGroup
FROM
    UserAccountEmailType JOIN
    EmailType ON EmailType.ID = UserAccountEmailType.EmailTypeID JOIN
    UserAccount ON UserAccount.ID = UserAccountEmailType.UserAccountID JOIN
    AssetGroup ON AssetGroup.ID = UserAccountEmailType.AssetGroupID
GO

CREATE VIEW ActiveSubscription AS
	SELECT 
		UserAccountEmailType.ID AS UserAccountEmailID,
		UserAccountEmailType.UserAccountID AS UserAccountID,
		UserAccountEmailType.Approved AS Approved,
		AssetGroup.Name AS AssetGroup,
		EmailType.Name AS EmailName,
		EmailCategory.Name AS Category,
		EmailType.ID AS EmailTypeID,
		SentEmail.Subject AS Subject,
		SentEmail.TimeSent AS LastSent,
        UserAccount.Name AS UserName,
		UserAccount.Email AS Email
	FROM UserAccountEmailType LEFT JOIN
		AssetGroup ON AssetGroup.ID = UserAccountEmailType.AssetGroupID LEFT JOIN
		EmailType ON UserAccountEmailType.EmailTypeID = EmailType.ID LEFT JOIN
		EmailCategory ON EmailCategory.ID = EmailType.EmailCategoryID LEFT JOIN
		SentEmail ON SentEmail.EmailTypeID = EmailType.ID  LEFT JOIN
		UserAccount ON UserAccount.ID = UserAccountEmailType.UserAccountID
GO

CREATE VIEW  MeterFacility AS
(
    SELECT
        CustomerMeter.ID AS ID,
        CustomerMeter.MeterID AS MeterID,
        Customer.PQIFacilityID AS FacilityID
    FROM
        Customer JOIN
        CustomerMeter ON CustomerMeter.CustomerID = Customer.ID
)
UNION
(
    SELECT
        CustomerAsset.ID AS ID,
        MeterAsset.MeterID AS MeterID,
        Customer.PQIFacilityID AS FacilityID
    FROM
        Customer JOIN
        CustomerAsset ON CustomerAsset.CustomerID = Customer.ID LEFT OUTER JOIN
        MeterAsset ON MeterAsset.AssetID = CustomerAsset.AssetID
)
GO

CREATE VIEW EmailTypeView
AS
SELECT
    EmailType.ID,
    EmailType.EmailCategoryID,
    EmailCategory.Name AS EmailCategory,
    EmailType.Name,
    EmailType.Template,
    EmailType.TriggerEmailSQL,
    EmailType.CombineEventsSQL,
    EmailType.MinDelay,
    EmailType.MaxDelay,
    EmailType.SMS,
    EmailType.ShowSubscription,
    EmailType.RequireApproval,
    EmailType.FilePath
FROM
    EmailType JOIN
    EmailCategory ON EmailType.EmailCategoryID = EmailCategory.ID
GO

CREATE TABLE StandardMagDurCurve(
	ID int IDENTITY(1,1) NOT NULL PRIMARY KEY,
	Name varchar(200) NOT NULL,
	Area Geometry NULL,
    Color varchar(255) NOT NULL,
)
GO

INSERT StandardMagDurCurve (Name, Area, Color) VALUES (N'ITIC', NULL, '#007a29')
GO
INSERT StandardMagDurCurve (Name, Area, Color) VALUES (N'SEMI F47', NULL, '#edc240')
GO
INSERT StandardMagDurCurve (Name, Area, Color) VALUES (N'IEEE 1668 Type I & II', NULL, '#a30000')
GO
INSERT StandardMagDurCurve (Name, Area, Color) VALUES (N'IEEE 1668 Type III', NULL, '#185aa9')
GO
INSERT StandardMagDurCurve (Name, Area, Color) VALUES (N'NERC PRC-024-2', NULL, '#d3d3d3')
GO
INSERT StandardMagDurCurve (Name, Area, Color) VALUES (N'IEEE 1159 Transients', NULL, '#afd8f8')
GO
INSERT StandardMagDurCurve (Name, Area, Color) VALUES (N'IEEE 1159 Instantaneous Sag', NULL, '#f47d23')
GO
INSERT StandardMagDurCurve (Name, Area, Color) VALUES (N'IEEE 1159 Instantaneous Swell', NULL, '#008c48')
GO
INSERT StandardMagDurCurve (Name, Area, Color) VALUES (N'IEEE 1159 Mom. Interruption', NULL, '#ee2e2f')
GO
INSERT StandardMagDurCurve (Name, Area, Color) VALUES (N'IEEE 1159 Momentary Sag', NULL, '#737373')
GO
INSERT StandardMagDurCurve (Name, Area, Color) VALUES (N'IEEE 1159 Momentary Swell', NULL, '#662c91')
GO
INSERT StandardMagDurCurve (Name, Area, Color) VALUES (N'IEEE 1159 Temp. Interruption', NULL, '#bd9b33')
GO
INSERT StandardMagDurCurve (Name, Area, Color) VALUES (N'IEEE 1159 Temporary Sag', NULL,'#ff904f')
GO
INSERT StandardMagDurCurve (Name, Area, Color) VALUES (N'IEEE 1159 Temporary Swell', NULL, '#ff9999')
GO
INSERT StandardMagDurCurve (Name, Area, Color) VALUES (N'IEEE 1159 Sustained Int.', NULL, '#0029A3')
GO
INSERT StandardMagDurCurve (Name, Area, Color) VALUES (N'IEEE 1159 Undervoltage', NULL, '#cb4b4b')
GO
INSERT StandardMagDurCurve (Name, Area, Color) VALUES (N'IEEE 1159 Overvoltage', NULL, '#4da74d')
GO

UPDATE StandardMagDurCurve SET Area = 'POLYGON((0.01 0.5, 0.2 0.5, 0.2 0.7, 0.5 0.7,0.5 0.8,2 0.8,2 1.0,0.01 1.0, 0.01 0.5))' WHERE Name = 'IEEE 1668 Type I & II'
GO
UPDATE StandardMagDurCurve SET Area = 'POLYGON((0.01 0.5, 0.05 0.5, 0.05 0.7, 0.1 0.7,0.1 0.8,2 1.0,0.01 1.0, 0.01 0.5))' WHERE Name = 'IEEE 1668 Type III'
GO
UPDATE StandardMagDurCurve SET Area = 'POLYGON((0.05 0.5, 0.2 0.5, 0.2 0.7, 0.5 0.7,0.5 0.8,1 0.8, 10 0.8, 10 0, 0 0, 0 0.5, 0.05 0.5))' WHERE Name = 'SEMI F47'
GO
UPDATE StandardMagDurCurve SET Area = 'POLYGON((0.0001667 5, 0.001 2, 0.003 1.4, 0.003 1.2,0.5 1.2,0.5 1.1, 100 1.1,100 0.9, 10 0.9, 10 0.8, 0.5 0.8, 0.5 0.7, 0.02 0.7, 0.02 0, 1000 0, 1000 5, 0.0001667 5))' WHERE Name = 'ITIC'
GO
UPDATE StandardMagDurCurve SET Area = 'POLYGON((0.001 1.2, 0.2 1.2, 0.2 1.175, 0.5 1.175,0.5 1.15,1 1.15, 1 1.10,4 1.10, 4 0.9, 3 0.9, 3 0.75, 2 0.75, 2 0.65, 0.3 0.65, 0.3 0.45, 0.15 0.45, 0.15 0, 0.001 0, 0.001 1.2))' WHERE Name = 'NERC PRC-024-2'
GO
UPDATE StandardMagDurCurve SET Area = 'POLYGON((0.000001 0, 0.01 0, 0.01 5.0, 0.000001 5.0, 0.000001 0))' WHERE Name = 'IEEE 1159 Transients'
GO
UPDATE StandardMagDurCurve SET Area = 'POLYGON((0.01 0.1, 0.5 0.1, 0.5 0.9, 0.01 0.9, 0.01 0.1))' WHERE Name = 'IEEE 1159 Instantaneous Sag'
GO
UPDATE StandardMagDurCurve SET Area = 'POLYGON((0.01 1.1, 0.5 1.1, 0.5 1.8, 0.01 1.8, 0.01 1.1))' WHERE Name = 'IEEE 1159 Instantaneous Swell'
GO
UPDATE StandardMagDurCurve SET Area = 'POLYGON((0.01 0, 3.0 0, 3.0 0.1, 0.01 0.1, 0.01 0))' WHERE Name = 'IEEE 1159 Mom. Interruption'
GO
UPDATE StandardMagDurCurve SET Area = 'POLYGON((0.5 0.1, 3.0 0.1, 3 0.9, 0.5 0.9, 0.5 0.1))' WHERE Name = 'IEEE 1159 Momentary Sag'
GO
UPDATE StandardMagDurCurve SET Area = 'POLYGON((0.5 1.1, 3.0 1.1, 3.0 1.4, 0.5 1.4, 0.5 1.1))' WHERE Name = 'IEEE 1159 Momentary Swell'
GO
UPDATE StandardMagDurCurve SET Area = 'POLYGON((3.0 0, 60.0 0, 60.0 0.1, 3.0 0.1, 3.0 0))' WHERE Name = 'IEEE 1159 Temp. Interruption'
GO
UPDATE StandardMagDurCurve SET Area = 'POLYGON((3.0 0.1, 60.0 0.1, 60.0 0.9, 3.0 0.9, 3.0 0.1))' WHERE Name = 'IEEE 1159 Temporary Sag'
GO
UPDATE StandardMagDurCurve SET Area = 'POLYGON((3.0 1.1, 60.0 1.1, 60.0 1.2, 3.0 1.2, 3.0 1.1))' WHERE Name = 'IEEE 1159 Temporary Swell'
GO
UPDATE StandardMagDurCurve SET Area = 'POLYGON((60.0 0, 1000.0 0, 1000.0 0.1, 60.0 0.1, 60.0 0))' WHERE Name = 'IEEE 1159 Sustained Int.'
GO
UPDATE StandardMagDurCurve SET Area = 'POLYGON((60.0 0.8, 1000.0 0.8, 1000.0 0.9, 60.0 0.9, 60.0 0.8))' WHERE Name = 'IEEE 1159 Undervoltage'
GO
UPDATE StandardMagDurCurve SET Area = 'POLYGON((60.0 1.1, 1000.0 1.1, 1000.0 1.2, 60.0 1.2, 60.0 1.1))' WHERE Name = 'IEEE 1159 Overvoltage'
GO

INSERT INTO AssetRelationshipTypeAssetType (AssetRelationshipTypeID, AssetTypeID ) VALUES
	((SELECT ID FROM AssetRelationshipType where Name = 'Transformer-(Single)Breaker'),(SELECT ID FROM AssetType WHERE Name = 'Transformer')),
	((SELECT ID FROM AssetRelationshipType where Name = 'CapBank-(Single)Breaker'),(SELECT ID FROM AssetType WHERE Name = 'CapacitorBank')),
	((SELECT ID FROM AssetRelationshipType where Name = 'Bus-Transformer'),(SELECT ID FROM AssetType WHERE Name = 'Line')),
	((SELECT ID FROM AssetRelationshipType where Name = 'Line-Transformer'),(SELECT ID FROM AssetType WHERE Name = 'Line')),
	((SELECT ID FROM AssetRelationshipType where Name = 'Line-CapBank'),(SELECT ID FROM AssetType WHERE Name = 'Line')),
	((SELECT ID FROM AssetRelationshipType where Name = 'DER-(Single)Breaker'),(SELECT ID FROM AssetType WHERE Name = 'DER')),
	((SELECT ID FROM AssetRelationshipType where Name = 'Line-DER'),(SELECT ID FROM AssetType WHERE Name = 'Line')),
	((SELECT ID FROM AssetRelationshipType where Name = 'DER-Transformer'),(SELECT ID FROM AssetType WHERE Name = 'DER')),
	((SELECT ID FROM AssetRelationshipType where Name = 'Bus-(Double)Breaker'),(SELECT ID FROM AssetType WHERE Name = 'Bus')),
	((SELECT ID FROM AssetRelationshipType where Name = 'Transformer-(Double)Breaker'),(SELECT ID FROM AssetType WHERE Name = 'Transformer'))
GO

INSERT INTO AssetRelationshipTypeAssetType (AssetRelationshipTypeID, AssetTypeID ) VALUES
	((SELECT ID FROM AssetRelationshipType where Name = 'Transformer-(Single)Breaker'),(SELECT ID FROM AssetType WHERE Name = 'Breaker')),
	((SELECT ID FROM AssetRelationshipType where Name = 'CapBank-(Single)Breaker'),(SELECT ID FROM AssetType WHERE Name = 'Breaker')),
	((SELECT ID FROM AssetRelationshipType where Name = 'Bus-Transformer'),(SELECT ID FROM AssetType WHERE Name = 'Transformer')),
	((SELECT ID FROM AssetRelationshipType where Name = 'Line-Transformer'),(SELECT ID FROM AssetType WHERE Name = 'Transformer')),
	((SELECT ID FROM AssetRelationshipType where Name = 'Line-CapBank'),(SELECT ID FROM AssetType WHERE Name = 'CapacitorBank')),
	((SELECT ID FROM AssetRelationshipType where Name = 'DER-(Single)Breaker'),(SELECT ID FROM AssetType WHERE Name = 'Breaker')),
	((SELECT ID FROM AssetRelationshipType where Name = 'Line-DER'),(SELECT ID FROM AssetType WHERE Name = 'DER')),
	((SELECT ID FROM AssetRelationshipType where Name = 'DER-Transformer'),(SELECT ID FROM AssetType WHERE Name = 'Transformer')),
	((SELECT ID FROM AssetRelationshipType where Name = 'Bus-(Double)Breaker'),(SELECT ID FROM AssetType WHERE Name = 'Breaker')),
	((SELECT ID FROM AssetRelationshipType where Name = 'Transformer-(Double)Breaker'),(SELECT ID FROM AssetType WHERE Name = 'Breaker'))
GO

CREATE TABLE AdditionalUserField(
	[ID] [int] IDENTITY(1,1) NOT NULL PRIMARY KEY,
	[FieldName] [varchar](100) NOT NULL,
	[Type] [varchar](max) NOT NULL DEFAULT ('string'),
	[IsSecure] [bit] NOT NULL DEFAULT (0),
) 
GO

CREATE TABLE AdditionalUserFieldValue(
	[ID] [int] IDENTITY(1,1) NOT NULL PRIMARY KEY,
    [UserAccountID] UNIQUEIDENTIFIER NOT NULL REFERENCES [UserAccount](ID),
	[AdditionalUserFieldID] [int] NOT NULL FOREIGN KEY References [AdditionalUserField](ID),
	[Value] [varchar](max) NULL,

)
GO

ALTER TABLE extDBTables ADD ExtDBID INT NOT NULL FOREIGN KEY References [ExternalDatabases](ID) DEFAULT 1
GO

CREATE TABLE [LocationDrawing] (
	ID int not null IDENTITY(1,1) PRIMARY KEY,
    LocationID INT not null FOREIGN KEY REFERENCES Location(ID),
    Name VARCHAR(200) NOT NUll,
    Link VARCHAR(max) NOT NUll,
    Description VARCHAR(max) NULL,
    Number VARCHAR(200) NULL,
    Category VARCHAR(max) NULL,
    CONSTRAINT UC_SystemCenter_LocationDrawing_Number UNIQUE (Number)
)
GO

INSERT INTO EventType(Name, Description) VALUES ('Snapshot', 'Snapshot')
GO

INSERT INTO EventTypeAssetType (EventTypeID,AssetTypeID) VALUES
	((SELECT ID FROM EventType WHERE Name = 'Fault'),(SELECT ID FROM AssetType WHERE Name = 'Transformer')),
	((SELECT ID FROM EventType WHERE Name = 'Fault'),(SELECT ID FROM AssetType WHERE Name = 'Line')),
	((SELECT ID FROM EventType WHERE Name = 'RecloseIntoFault'),(SELECT ID FROM AssetType WHERE Name = 'Breaker')),
	((SELECT ID FROM EventType WHERE Name = 'BreakerOpen'),(SELECT ID FROM AssetType WHERE Name = 'Breaker')),
	((SELECT ID FROM EventType WHERE Name = 'Interruption'),(SELECT ID FROM AssetType WHERE Name = 'Bus')),
	((SELECT ID FROM EventType WHERE Name = 'Sag'),(SELECT ID FROM AssetType WHERE Name = 'Bus')),
	((SELECT ID FROM EventType WHERE Name = 'Swell'),(SELECT ID FROM AssetType WHERE Name = 'Bus')),
	((SELECT ID FROM EventType WHERE Name = 'Transient'),(SELECT ID FROM AssetType WHERE Name = 'Bus')),
	((SELECT ID FROM EventType WHERE Name = 'Interruption'),(SELECT ID FROM AssetType WHERE Name = 'CapacitorBank')),
	((SELECT ID FROM EventType WHERE Name = 'Sag'),(SELECT ID FROM AssetType WHERE Name = 'CapacitorBank')),
	((SELECT ID FROM EventType WHERE Name = 'Swell'),(SELECT ID FROM AssetType WHERE Name = 'CapacitorBank')),
	((SELECT ID FROM EventType WHERE Name = 'Transient'),(SELECT ID FROM AssetType WHERE Name = 'CapacitorBank')),
	((SELECT ID FROM EventType WHERE Name = 'Snapshot'),(SELECT ID FROM AssetType WHERE Name = 'Bus')),
	((SELECT ID FROM EventType WHERE Name = 'Snapshot'),(SELECT ID FROM AssetType WHERE Name = 'Breaker'))
GO
